<template>
  <el-form ref="form" :model="form" :rules="rules" label-width="100px" size="small">
    <!--智能安全校验-->
    <el-form-item :label="$t('largeModel.intelligentSafetyCheck')+':'" prop="intelligentSafetyCheck" >
      <el-switch v-model="form.intelligentSafetyCheck"></el-switch>
      <div class="switch-title">{{$t('largeModel.intelligentSafetyTip')}}</div>
    </el-form-item>
    <!--校验等级-->
    <el-form-item :label="$t('largeModel.checkLevel')+':'" prop="checkLevel" v-show="form.intelligentSafetyCheck">
      <div class="level-container">
        <!--严格-->
        <el-radio v-model="form.level" label="3">{{$t('largeModel.strict')}}</el-radio>
        <!--校验过滤低、中、高级别敏感词 -->
        <div class="level-title">{{$t('largeModel.strictTip')}}</div>
      </div>
      <div class="level-container">
        <!--中度-->
        <el-radio v-model="form.level" label="2">{{$t('largeModel.medium')}}</el-radio>
        <!--校验过滤中、高级别敏感词，和系统内置词库中的敏感词。包括具争议性、不太适合公开讨论的词汇，或者在特定领域被认为是敏感的词汇，以及涉及严重违法、违规、有害或极端不适宜的内容等 -->
        <div class="level-title">{{$t('largeModel.mediumTip')}}</div>
      </div>
      <div class="level-container">
        <!--普通-->
        <el-radio v-model="form.level" label="1">{{$t('largeModel.common')}}</el-radio>
        <!--仅校验过滤高级别敏感词。涉及严重违法、违规、有害或极端不适宜的内容等 -->
        <div class="level-title">{{$t('largeModel.commonTip')}}</div>
      </div>
    </el-form-item>
  </el-form>
</template>

<script>
import {mapGetters} from "vuex";
import {
  getModelSecurity,saveModelSecurity
} from '@/api/aiccApi/aiccLargeModel/index'
export default {
  computed: {
    ...mapGetters(['currentTenantId']),
  },
  data(){
    return {
      form:{
        intelligentSafetyCheck:true,
        level:'1',
      },
    }
  },
  methods: {
    saveSafetyForm() {
      var info = {
        open: this.form.intelligentSafetyCheck?1:0,//数字：0 关闭，1 开启
        level:this.form.level,//数字：3 严格， 2 中等， 1 低
        tenantId: this.currentTenantId
      }
      saveModelSecurity(info).then(res=>{
        if(res.data.code == 200) {
          this.$message({
            type: 'success',
            message: this.$t('aiccCommon.successSave')
          })
          this.$emit('closeSafetyDrawer')
        }
      })
    }
  },
  async mounted() {
    const resData  = await getModelSecurity({tenantId: this.currentTenantId})
    if(resData.data.code == 200) {
      var saveData = resData.data.data
      this.form.intelligentSafetyCheck = saveData.open == '1'?true:false
      this.form.level = saveData.level + ''
    }
  }
}
</script>

<style scoped lang="scss">
.level-container{
  .level-title{
    font-size: 12px;
    color:#9597a0;
    line-height: 2;
  }
}
.switch-title {
  font-size: 12px;
  color:#9597a0;
  line-height: 2;
  display: inline-block;
  margin-left: 10px;
  vertical-align: middle;
}
</style>
